package com.rongshu.view.login.presenter;

import android.util.Log;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.login.contract.LoginQuestionView;
import com.rongshu.view.login.entity.LoginQuestion;
import rx.Subscriber;
import rx.functions.Action0;

public class LoginQuestionPresenter {

    private LoginQuestionView mView;

    public LoginQuestionPresenter(LoginQuestionView view) {
        this.mView = view;
    }

    /**
     * 获取登录遇到的问题
     */
    public void getLoginProblems(int rnd, String sign) {
        RetorfitService.getLoginProblems(rnd, sign)
                .doOnSubscribe(new Action0() {
                    @Override
                    public void call() {

                    }
                })
                .subscribe(new Subscriber<LoginQuestion>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(LoginQuestion loginQuestion) {
                        if (mView != null) {
                            mView.loginProblems(loginQuestion);
                        }
                    }
                });
    }
}
